<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/layui.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/css/vote.css}"/>
    <link rel="stylesheet" th:href="@{/css/daohang.css}"/>


</head>
<body bgcolor="">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend><span class="" style="font-size: 14px">
  <a href="">投票管理<span class="layui-box">&gt;</span></a>
  <a href="">投票情况<span class="layui-box">&gt;</span></a>
</span>
    </legend>
</fieldset>

<div class="site-demo-button bo" id="layerDemo" style="margin-bottom: 0;">
    <div lay-skin="line" class="tips zhong">
    </div>
</div>

<script th:src="@{/layui/layui.all.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/js/jquery-3.2.1.js}"></script>

<script>
    $(function () {
        $.get('/dor/VCS', function (data) {
            var htmls = []

            data.forEach(
                function (item, index) {
                    var demo = '<div class="kk">' + '<img style="width: 180px;height: 140px" src="' + item.img + '" id="imgId"/>'
                        + '<hr />' + '<div class="layui-form-item" >' + '<label class="layui-form-label qins1">'
                        + '寝室' + item.fang + '</label>' + '<p class="piao1">' + '票数:' + '<a >' + item.count +
                        '</a>' + '</p>'  + '</div>' + '</div>'

                    htmls.push(demo)
                })


            $('.tips').html(htmls.join(''))
            layui.use('layer', function () { //独立版的layer无需执行这一句
                var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
            })
        })
    })

    function toupiao(n, id) {

        $.get("/dor/testVote/" + id, function (data) {
            if (data) {
                if (confirm('是否确定投票！')) {
                    $.get("/dor/addVC/" + id, function (data) {
                        var par = $(n).parents('.layui-form-item');
                        var count = $(par).children('.piao');
                        var s = $(count).children('a').html();
                        $(count).children('1a').html(parseInt(s) + 1);
                    });
                }
            } else {
                layer.confirm('您已投了票！', function (q) {
                    layer.close(q);

                })
            }
        })
    };


</script>
<script th:inline="javascript">
    $.get('/dor/VCC',function (data) {
         /*alert(data)*/

  /*  var flag = [[${voteCount}]];
    console.log(flag);*/
    if (data === 0) {
        layer.open({
            content: '暂时无人报名'
        });
    }
    })
</script>

</body>
</html>